#include <iostream>
using namespace std;

const int N = 100010;
int n, x;

class mon_stack
{
private:
    int stk[N];
    int tt;
    int mon;

public:
    mon_stack(int m = 1);
    int push(int x);
    int pop();
    bool is_empty();
    int query();
};

mon_stack::mon_stack(int m)
{
    mon = m;
    tt = -1;
}

int mon_stack::push(int x)
{
    int res = -1;
    while (!is_empty() && (mon * stk[tt]) >= (x * mon))
        --tt;
    if (!is_empty())
        res = query();
    stk[++tt] = x;
    return res;
}

int mon_stack::pop()
{
    return stk[tt--];
}

bool mon_stack::is_empty()
{
    return tt < 0;
}

int mon_stack::query()
{
    return stk[tt];
}

int main()
{
    mon_stack f_stk;
    scanf("%d", &n);
    while (n--)
    {
        scanf("%d", &x);
        printf("%d ", f_stk.push(x));
    }
    return 0;
}